<?php
 
class EventTypesController extends AppController {

/**
 * Uses array
 *
 * @var array
 */
	var $name = 'EventTypes';

/**
 * Helpers
 *
 * @var array
 **/
  public $components = array('RequestHandler');
  public $helpers = array('Html', 'Form', 'Paginator', 'Js' => array('Jquery'));

/**
 * Pagination
 *
 * @var array
 **/
  var $paginate = array(
        'limit' => 15
  );

/**
 * @method: index
 * @purpose: list of all event types
 * @param none
 * @return void
 **/
	function admin_index() {
		$this->EventType->recursive = 0;
		$this->set('eventTypes', $this->paginate());
	}

/**
 * @method: view
 * @purpose: admin to view event type
 * @param none
 * @return void
 **/
	function admin_view($id = null) {
		if(!$id) {
			$this->Session->setFlash(__('Invalid event type', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('eventType', $this->EventType->read(null, $id));
	}

/**
 * @method: add
 * @purpose: admin to add event type
 * @param none
 * @return void
 **/
	function admin_add() {
		if (!empty($this->data)) {
			$this->EventType->create();
			if ($this->EventType->save($this->data)) {
				$this->Session->setFlash(__('The event type has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The event type could not be saved. Please, try again.', true));
			}
		}
	}

/**
 * @method: edit
 * @purpose: admin to update event type
 * @param none
 * @return void
 **/
	function admin_edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid event type', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->EventType->save($this->data)) {
				$this->Session->setFlash(__('The event type has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The event type could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->EventType->read(null, $id);
		}
	}

/**
 * @method: delete
 * @purpose: admin to delete event type
 * @param none
 * @return void
 **/
	function admin_delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for event type', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->EventType->delete($id)) {
			$this->Session->setFlash(__('Event type deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Event type was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
  
  
}